/*
 * @Author: your name
 * @Date: 2021-09-22 13:39:54
 * @LastEditTime: 2021-09-23 16:18:35
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \product-display\src\api\api.js
 */
import { request } from '@/utils/request'

/**
 * 获取所有分类
 * @returns
 */
export function getProductCategoryList () {
  return request({
    url: '/management-platform/productcategory',
    method: 'get'
  })
}

/**
 * 新增分类
 * @returns
 */
export function addProductCategory (data) {
  return request({
    url: '/management-platform/productcategory',
    method: 'post',
    data
  })
}

/**
 * 更新分类
 * @returns
 */
export function updateProductCategory (data) {
  return request({
    url: '/management-platform/productcategory',
    method: 'put',
    data
  })
}

/**
 * 删除分类
 * @returns
 */
export function deleteProductCategory (params) {
  return request({
    url: '/management-platform/productcategory',
    method: 'delete',
    params
  })
}

/**
 * 新增商品
 * @returns
 */
export function addProduct (params) {
  return request({
    url: '/management-platform/batch/upload',
    method: 'post',
    data: params,
    headers: {'Content-Type': 'multipart/form-data'}
  })
}

/**
 * 新增商品详情
 * @returns
 */
export function updateProductDetail (params) {
  return request({
    url: '/management-platform/batch/upUpload',
    method: 'post',
    data: params
  })
}

/**
 * 获取商品列表
 * @returns
 */
export function getProductList (params) {
  return request({
    url: '/management-platform/image',
    method: 'get',
    params
  })
}

/**
 * 获取商品详情
 * @returns
 */
export function getProductDetail (params) {
  return request({
    url: '/management-platform/imageDetail',
    method: 'get',
    params
  })
}

/**
 * 删除商品
 * @returns
 */
export function deleteProduct (id) {
  return request({
    url: '/management-platform/image/' + id,
    method: 'delete'
  })
}

/**
 * 删除商品详情
 * @returns
 */
export function deleteProductDetail (id) {
  return request({
    url: '/management-platform/imageDetails/' + id,
    method: 'delete'
  })
}
